import json
from itertools import chain

import torch

ts1 = torch.randn(3, 5)
print(ts1)
temp = (ts1>0)
print(temp)

print(temp.sum(1))
print(temp.sum(0))


print(ts1[temp])


predict = [[6, 5, 3, 0, 8, 0, 0, 0, 0, 0, 4, 8, 8, 0, 0, 0, 0, 3, 5, 0, 8, 8, 0, 3, 0, 0, 0, 3, 3, 5, 3, 7, 4, 4, 8, 0], [8, 8, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [4, 4, 8, 8, 8, 8, 10, 0, 3, 5, 5, 0, 8, 8, 8, 8, 8, 8, 0, 8, 8, 0], [8, 8, 5, 0, 0], [3, 9, 11, 8, 8, 8, 0], [8, 8, 8, 8, 8, 0, 2, 0, 0, 0], [5, 3, 5, 8, 8, 8, 0, 0, 0, 0, 0, 0], [5, 3, 5, 0, 0, 3, 0, 8, 8, 8, 0, 0, 0]]
real = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 0, 5, 6, 0, 3, 4, 4, 5, 6, 0, 3, 4, 4, 0, 3, 4, 4, 0, 0, 0, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 3, 4, 0, 5, 6, 0, 3, 4, 4, 0, 0, 5, 6, 0, 0, 0, 0, 7, 8, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 7, 8, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 7, 8, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 3, 4, 4, 5, 6, 7, 8, 0]

total_elements = 0
for sublist in predict:
    total_elements += len(sublist)
print(total_elements)

print(len(real))


ts2 = torch.tensor([1,2,3]).tolist()
lt = []
lt.extend(ts2)
print(f'ts2--->{ts2}')
